include_directories(${CMAKE_SOURCE_DIR}/include)

# compile to a lib single
add_library(lib_demo OBJECT demo.c)

# main.c compile to a executable file, because of containing main func
add_executable(demo main.c)

# finally exe file link with lib
# target_link_libraries(lib_demo ${CMAKE_SOURCE_DIR}/lib/libopensrc.a)
# target_link_libraries(demo lib_demo ${CMAKE_SOURCE_DIR}/lib/libopensrc.a)
target_link_libraries(demo lib_demo)

# TODO How to add a new src file on exist exe, and make it compile together
# 1. new a file, such as named newfile.c
# 2. if this file compile into lib, then append the filename to add_library() parameter_list tail
# 3. if this file compile into exe, then append the filename to add_executable() parameter_list tail

# TODO How to add a new exe file?
# 1. new a file which named .c/.cpp in src folder, such as newfile.c
# 2. add one line of add_executable(newfile newfile.c)
# 3. run cmake build once

# pay attention
# 1. header file should add to include directory, if you add into other folder, must call marco include_directory()
# 2. if a new file neither add_library, nor add_executable, it will not be compile
